package com.stephenone.zhdaily.homepage;

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import com.stephenone.zhdaily.R;
import com.stephenone.zhdaily.data.source.NewsRepository;
import com.stephenone.zhdaily.data.source.local.NewsLocalDataSource;
import com.stephenone.zhdaily.data.source.remote.NewsRemoteDataSource;
import com.stephenone.zhdaily.uitl.ActivityUtils;
import com.stephenone.zhdaily.uitl.schedulers.SchedulerProvider;


public class HomepageActivity extends AppCompatActivity {

    private static final String TAG = HomepageActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_homepage);

        // Set up the toolbar.
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        ActionBar ab = getSupportActionBar();
//        ab.setDisplayHomeAsUpEnabled(true);
//        ab.setDisplayShowHomeEnabled(true);

        HomepageFragment homepageFragment = (HomepageFragment) getSupportFragmentManager()
                .findFragmentById(R.id.contentFrame);

        if (homepageFragment == null) {
            homepageFragment = HomepageFragment.newInstance();

            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                    homepageFragment, R.id.contentFrame);
        }

        new HomepagePresenter(NewsRepository.getInstance(NewsRemoteDataSource.getInstance(), NewsLocalDataSource.getInstance(getApplicationContext(), SchedulerProvider.getInstance())),homepageFragment,SchedulerProvider.getInstance());
        Log.e(TAG, "onCreate: ");
    }




    @Override
    public boolean onSupportNavigateUp() {
//        onBackPressed();
        return true;
    }
}
